package mp

import (
	"duoke/model"
	"duoke/service"
	"duoke/utils/response"
	"github.com/gin-gonic/gin"
	"github.com/gogf/gf/v2/container/gvar"
)

var Kuaidi = new(kuaidiCtl)

type kuaidiCtl struct{}

func (ctl *kuaidiCtl) Info(c *gin.Context) {
	var req model.SearchFastMail
	if err := c.ShouldBind(&req); err != nil {
		response.Error(c, err.Error(), nil)
		return
	}
	if req.Num == "" || req.Types == "" {
		response.Error(c, "参数缺失【num/types】", nil)
		return
	}
	info, err := service.FastMail.Info(c, &model.SearchFastMail{Num: req.Num, Types: req.Types})
	if err != nil {
		info = nil
		info.Id = 0
	} else {
		info.Data = gvar.New(info.Data, true).Array()
	}
	response.Success(c, "查询成功", info)
}
